﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevIsMagic.ViewModel;
using System.Collections.ObjectModel;
using Demo.Business;

namespace Demo
{
	public class ContactsViewModel : ViewModelBase
	{
		public ColumnViewModelCollection Columns { get; private set; }
		public ObservableCollection<Contact> Contacts { get; private set; }

		public ContactsViewModel()
		{
			this.Contacts = new ObservableCollection<Contact>
			{
				new Contact{ FirstName="John", LastName="Smith", DateOfBirth=new DateTime(1988, 12, 2)},
				new Contact { FirstName="Edward", LastName="Doo", DateOfBirth=new DateTime(1912, 8, 6)}
			};
			if (Properties.Settings.Default.ColumnsPrefs == null)
			{
				Properties.Settings.Default.ColumnsPrefs = new ColumnViewModelCollection
				{
					new ColumnViewModel { Header="FirstName", MemberName="FirstName" },
					new ColumnViewModel { Header="LastName", MemberName="LastName", Visible=false},
					new ColumnViewModel { Header="Date of birth", MemberName="DateOfBirth", Width=200}
				};
			}
			this.Columns = Properties.Settings.Default.ColumnsPrefs;

		}
	}
}
